home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource5 / 349_01 / sss.arc / TUTOR.SSS < prev   
Encoding:
Text File  |  1991-04-17  |  69.8 KB  |  1,843 lines

  1.             SOLVED EXERCISES IN SIMULATION USING SSS
  2.             ========================================
  3.  
  4.       by M. A. Pollatschek, IE Technion, Haifa 32000 ISRAEL
  5.  
  6.                       How to use this file
  7.                       ====================
  8. The exercises below are ordered by their complexity. To fully
  9. benefit from them proceed to the next exercise when the solutions
  10. of the previous ones are clear. The actual computer codes for
  11. exercise x.y are in files EX_0x0y.* (* = BAS, C, FOR, PAS).
  12. Compare the relevant part of this file with them as well as files
  13. MANUAL.SSS and GLOSSARY.SSS. Use index in the end with an
  14. editor's (or lister's or word processor's) search facility to
  15. quickly locate topics. Editors showing at once up to four files
  16. are especially helpful. (Can be obtained from author by sending a
  17. DOS formatted 340K 5.25" diskette in a selfaddressed mailer + $30
  18. to cover expenses.)
  19.  
  20.                           EXERCISE 2.1
  21.                           ============
  22. Problem statement
  23. -----------------
  24.   Simulate the arrival of ships to a harbor during ten days if
  25.   known that on the average two ships enter the port in one day.
  26.   Assume that the probability of a ship's appearance during any
  27.   second is the same irrespective of the time of the day, the
  28.   date or other ship's arrivals. [Listing 1]
  29.  
  30. New simulation concept
  31. ----------------------
  32. * Simulation of processes evolving in time
  33.  
  34. New SSS routine
  35. ---------------
  36.   EX(M)  Random exponential variate with mean M, models well
  37.          random interarrival times
  38.  
  39. Variable
  40. --------
  41.   pt = present time
  42.  
  43. Points to observe
  44. -----------------
  45. * Two ships per day means that mean interarrival time between
  46.   ships is 1/2 day
  47. * In SSS you decide upon the time units, but STICK to one unit
  48.   through the model (do not mix days and hours, etc).
  49.  
  50. Pseudo code
  51. -----------
  52.   Set present time to first arrival as a random variate (EX(0.5)).
  53.   Loop until present time is less then 10:
  54.     add random interarrival time (EX(0.5)) to present time.
  55.   End of loop.
  56.  
  57. Tutor SSS                                                  Page 2
  58.  
  59.                           EXERCISE 2.6
  60.                           ============
  61. Problem statement
  62. -----------------
  63.   Simulate telephone conversations of a manager during two
  64.   hours. The time between conclusion of a call and the start of
  65.   the next is normally distributed with mean 7 minutes and
  66.   standard deviation 4 minutes. Quarter of the calls are to new
  67.   customers, their length is distributed by the Erlang
  68.   distribution with two stages and average length of 4 minutes.
  69.   The rest of the calls are triangularly distributed between 1
  70.   and 4 minutes and mode 3 minutes. [Listing 2]
  71.  
  72. New simulation concept
  73. ----------------------
  74.   Choice in a random manner with given probabilities by calling
  75.   RA()
  76.  
  77. New SSS routines
  78. ----------------
  79.   RA()       Random number between 0 and 1
  80.   RN(M,S)    Random normal variate with mean M and standard
  81.              deviation S
  82.   TR(I,B,C)  Random normal deviate from triangular distribution
  83.              with minimum I, maximum C and mode B
  84.  
  85. Programming tip
  86. ---------------
  87.   To keep random normal variate non negative call RN() via
  88.   subroutine rnx() which does not let through a negative value
  89.  
  90. Variable
  91. --------
  92.   pt = present time
  93.  
  94. Subroutine
  95. ----------
  96.   rnx(m, s) returns a normal variate with mean m, standard
  97.             deviation s while the negative part is truncated
  98.  
  99. Pseudo code of main routine
  100. ---------------------------
  101.   Set present time to time that first call comes in.
  102.   Loop:
  103.     Advance present time to end of present conversation:
  104.       with probability 1/4 by a random Erlang variate,
  105.       with complimentary probability by a random triangular
  106.         variate.
  107.     Advance present time to start of next call by a (truncated)
  108.       normal variate.
  109.   Loop until present time passes 120.
  110.  
  111. Tutor SSS                                                  Page 3
  112.  
  113.                           EXERCISE 2.9
  114.                           ============
  115. Problem statement
  116. -----------------
  117.   Collect the statistics of all the call lengths in 2.6
  118.   irrespective of their origin and the cycle time.
  119.   Report both on screen and file RESULTS. [Listing 3]
  120.  
  121. New SSS routines
  122. ----------------
  123.   INIQUE(0,0,s)       Initializes s statistics collection
  124.   INISTA(j,h,0,l,f,w) Initializes j-th statistic collection
  125.   TALLY(j,v)          Registers v for statistic j
  126.   SUMRY(u)            Prints out standard report
  127.  
  128. Programming tips
  129. ----------------
  130. * Keep most variables global (common in FORTRAN, common
  131.   shared in BASIC).
  132. * Keep all the initializations (such as call to INIQUE) in
  133.   subroutine prime.
  134.  
  135. Variables
  136. ---------
  137.   pt = present time
  138.   pv = time that previous conversation ended
  139.   x  = time of conversation
  140.  
  141. Statistics
  142. ----------
  143.   1. for x
  144.   2. for pt - pv when pt = end of present conversation
  145.  
  146. Subroutines
  147. -----------
  148.   prime()   Initializes statistics, pt (start of first call) and
  149.             pv.
  150.   rnx(m, s) Returns a normal variate with mean m, standard
  151.             deviation s while the negative part is truncated.
  152.  
  153. Pseudo code of main routine
  154. ---------------------------
  155.   Initialize.
  156.   Loop:
  157.     Let length of call be x, a random variate taken from
  158.       Erlang distribution with probability 1/4
  159.       triangular distribution with complimentary probability.
  160.     Collect observation x.
  161.     Advance present time, pt, to end of call.
  162.     Collect time from previous end of call (pv) to the present
  163.       one (pt).
  164.     Save pt in pv for next time.
  165.     Advance present time to start of next call by a (truncated)
  166.       normal variate.
  167.   Loop until present time passes 120.
  168.   Print out standard report on screen and file RESULTS.
  169.  
  170. Tutor SSS                                                  Page 4
  171.  
  172.                           EXERCISE 3.1
  173.                           ============
  174. Problem statement
  175. -----------------
  176.   What is the fraction of time in 2.6 that the phone is busy?
  177.   [Listing 4]
  178.  
  179. New simulation concepts
  180. -----------------------
  181. * Stochastic process: a variable having a value at each time
  182.   (such as state of a phone [free=0, busy=1]) where time average
  183.   counts rather than ordinary average.
  184. * Time persistent statistic: statistic about a stochastic
  185.   process.
  186.  
  187. New SSS routines
  188. ----------------
  189.   INISTA(j,h,1,l,f,w) Initializes time persistent statistic
  190.   SETT(g)             Sets simulated time to g
  191.   T()                 Returns simulated time
  192.  
  193. Programming tips
  194. ----------------
  195. * Denote states by constants (in FORTRAN as common variables
  196.   initialized in prime()).
  197. * Use of SSS subroutines saves variables.
  198.  
  199. Constants
  200. ---------
  201.   free (0)  State of phone being free
  202.   busy (1)  State of phone being busy
  203.  
  204. Statistic
  205. ---------
  206.   1. for free and busy - time persistent
  207.  
  208. Subroutines
  209. -----------
  210.   prime()   Initializes statistics, arrival of first call,
  211.             registration of phone's states.
  212.   rnx(m, s) Returns a normal variate with mean m, standard
  213.             deviation s while the negative part is truncated.
  214.  
  215. Pseudo code of main routine
  216. ---------------------------
  217.   Initialize.
  218.   Loop:
  219.     Advance simulated time to end of call by a random variate
  220.       taken from -
  221.       Erlang distribution with probability 1/4
  222.       triangular distribution with complimentary probability.
  223.     Register change of phone's state for utilization statistics
  224.     Advance simulated time to start of next call by a (truncated)
  225.       normal variate.
  226.     Register change of phone's state for utilization statistics.
  227.   Loop until present time passes 120.
  228.   Print standard report.
  229.  
  230. Tutor SSS                                                  Page 5
  231.  
  232.                           EXERCISE 3.5
  233.                           ============
  234. Problem statement
  235. -----------------
  236.   Simulate the inventory of a photo shop concerning a single
  237.   type of camera. There is a customer for the camera every two
  238.   days on the average. The shop gets new cameras every 30 days so
  239.   that it starts a new period of 30 days always with 15 cameras
  240.   on the shelf, no matter how many has been sold. Simulate three
  241.   periods of 30 days to know the number of requests which cannot
  242.   be satisfied and the average stock. [Listing 5]
  243.  
  244. Subroutine
  245. -----------
  246.   prime()   initializes statistics
  247.  
  248. Variables
  249. ---------
  250.   i = index of month, each one having 30 days
  251.   c = stock
  252.  
  253. Statistics
  254. ----------
  255.   1. 1 every time that c = 0 when a customer arrives
  256.   2. for c - time persistent
  257.  
  258. Pseudo code of main routine
  259. ---------------------------
  260.   Initialize.
  261.   For each of the 3 months do:
  262.     Start stock (in the beginning of month) at 15.
  263.     Set simulated time to start of month.
  264.     Register stock level to 2nd (time persistent) statistics.
  265.     Advance time to first customer's arrival.
  266.     While still in present month do:
  267.       If there is stock, decrease it-this is selling to customer
  268.       Otherwise (if cannot sell), count case of out of stock
  269.         condition.
  270.       Register stock level to 2nd (time persistent) statistic.
  271.       Advance simulated time to following customer's arrival.
  272.   Print standard report.
  273.  
  274. Tutor SSS                                                  Page 6
  275.  
  276.                           EXERCISE 4.3
  277.                           ============
  278. Problem statement
  279. -----------------
  280.   What is the satisfactory size of a parking lot for a shop if
  281.   known that at peak hours the arrival rate is 30 customers per
  282.   hour and each one spends in the shop 20 minutes on the average.
  283.   Assume that each customer arrives in one car and the cars are
  284.   of approximately the same size. [Listing 7]
  285.  
  286. New simulation concepts
  287. -----------------------
  288. * Entity: a car owner or a similar object which goes through the
  289.   system.
  290. * Current entity: the entity under consideration. Maximum one
  291.   entity should be current at any given time in the code,
  292.   although conceptually, many parallel activities can be
  293.   simulated.
  294. * Event: change of state at a certain instant such as another car
  295.   in the parking lot.
  296. * Calendar: the list of entities whose events should occur in
  297.   some future time. New entities are placed on the calendar by
  298.   subroutine CREATE and current entity by subroutine SCHED.
  299. * Event code: a positive integer characterizing an event. Each
  300.   event has a distinct event code. Event code 1 is preserved for
  301.   the arrival event.
  302. * Event loop: "case loop" (or its equivalent in FORTRAN) which is
  303.   driven by the entities in the calendar and function NEXTEV
  304.   which removes the entity from the calendar whose event time is
  305.   closest to present simulated time and makes it current. NEXTEV
  306.   returns the event code of the entity, which is directed to its
  307.   respective label (such as ARRIVL). Event code 0 causes to exit
  308.   the event loop. NEXTEV returns 0 when the calendar is empty or
  309.   time set by SIMEND arrived.
  310.  
  311. New SSS routines
  312. ----------------
  313.   CREATE(g,i)  Creates an arrival in time g from present time
  314.                with id i
  315.   DISPOS()     Destroys current entity if exists
  316.   NEXTEV()     Returns event code of following event
  317.   SCHED(g,e,i) Schedules event e>1 for time g from present time
  318.                with id i
  319.   SIMEND(g)    Ends simulation at time g (absolute)(g=0: end now)
  320.  
  321. Programming tips
  322. ----------------
  323. * Always put entities in the calendar in the initialization,
  324.   otherwise the program does not enter to event loop.
  325. * "Hiding" the code of an event or parts of it in a subroutine
  326.   improves readability and ease of maintenance.
  327. * Dispose the entity as soon as its presence is not necessary.
  328. * SCHED(0,e,i) acts as "goto" for an entity.
  329.  
  330. Tutor SSS                                                  Page 7
  331.  
  332. Constants
  333. ---------
  334.   ARRIVL(1) Event code of new arrival to the system
  335.   STARTA(2) Event code of starting an activity (parking and
  336.             buying)
  337.   ENDACT(3) Event code of ending activity (picking up the car
  338.             and leaving)
  339.  
  340. Variables
  341. ---------
  342.   c     = number of parking cars
  343.   ecode = current value of event code
  344.  
  345. Statistic
  346. ---------
  347.   1. for c - time persistent
  348.  
  349. Subroutines
  350. -----------
  351.   prime()   Initializes statistics, sets simulation end at 40
  352.             time units, creates the first customer arrival, sets
  353.             initial number of parking cars to 0 and registers it
  354.             for collecting time persistent statistics.
  355.   leavec()  Increase the number of parking cars, register it for
  356.             time persistent statistic, schedule time when car is
  357.             picked up as a random time interval from now.
  358.   pickc()   Decrease the number of parking cars, register it for
  359.             time persistent statistic. Customer leaves the lot
  360.             (DISPOS).
  361.  
  362. Pseudo code of main routine
  363. ---------------------------
  364.   Initialize.
  365.   The event loop:
  366.     A new entity arrives (ARRIVL):
  367.       Create next customer's arrival in a random time from now
  368.         (EX(2)) and send customer to park car (STARTA)
  369.     Parking the car (STARTA):
  370.       Perform the code in subroutine leavec().
  371.     Picking up the car (ENDACT):
  372.       Perform the code in subroutine pickc().
  373.   End of event loop.
  374.   Print standard report.
  375.  
  376. Tutor SSS                                                  Page 8
  377.                           EXERCISE 4.1
  378.                           ============
  379. Problem statement
  380. -----------------
  381.   Assume that the reorder policy of the camera shop in 3.5 is
  382.   that every time the stock falls below 4 cameras, an order is
  383.   placed for 12 cameras. Generally 7 days pass until the supply
  384.   is obtained, but deviation of up to 2 days is expected.
  385.   Simulate the shop for 40 days when the starting stock is 15.
  386.   [Listing 6]
  387.  
  388. New SSS routine
  389. ---------------
  390.   IDE()        Returns identity of current entity
  391.  
  392. Point to observe
  393. ----------------
  394.   All the new entities, no matter what they are (e.g. whether
  395.   customers or shipments) introduced to the system at label
  396.   ARRIVL.
  397.  
  398. Programming tips
  399. ----------------
  400. * Counting can be performed by TALLY(j,1) if j is regular (not
  401.   time persistent) statistic.
  402. * Set distinct identities for each entity type and separate them
  403.   by assigned identity code (last parameter in CREATE & SCHED).
  404.  
  405. Constants
  406. ---------
  407.   ARRIVL(1) Event code of new arrival to the system
  408.   TRYBUY(2) Event code that a customer wishes to buy
  409.   REPLNS(3) Event code that a new shipment replenishes stock
  410.   CUSTMR(0) Identity code of a customer
  411.   GOODS (1) Identity code of a new shipment
  412.  
  413. Variables
  414. ---------
  415.   c     = stock level of cameras
  416.   ecode = current value of event code
  417.  
  418. Types of entities (identities)
  419. ------------------------------
  420.   0: customer
  421.   1: new shipment
  422.  
  423. Statistics
  424. ----------
  425.   1. 1 every time that c = 0 when a customer arrives, counts
  426.      dissatisfied customers
  427.   2. for c - time persistent
  428.  
  429. Tutor SSS                                                  Page 9
  430.  
  431. Subroutines
  432. -----------
  433.   prime()   Initializes statistics, sets simulation end at 40
  434.             time units, creates the first customer arrival, sets
  435.             initial stock to 15 and registers it for collecting
  436.             time persistent statistics.
  437.   buying () If stock reaches level 4, it enters an order for a
  438.             new shipment by creating GOODS arrival a random time
  439.             from now (from the triangular distribution). If there
  440.             is stock, it is decreased by 1 by the purchase. If
  441.             there is no stock it counts (by TALLY) the
  442.             unsatisfied customer. It registers the new stock
  443.             level for the time persistent statistic.
  444.   order ()  Stock is increased by 12. It registers the new stock
  445.             level for the time persistent statistic.
  446.  
  447. Pseudo code of main routine
  448. ---------------------------
  449.   Initialize.
  450.   The event loop:
  451.     A new entity arrives (ARRIVL):
  452.       If it is a customer, create next customer's arrival in a
  453.         random time from now (EX(2)) and send the entity to buy.
  454.       If it is not a customer (e.i., it is a shipment) send it to
  455.         replenish the stock.
  456.     Buying by a customer (TRYBUY):
  457.       Perform the code in subroutine buying().
  458.     Replenishing stock (REPLNS):
  459.       Perform the code in subroutine order().
  460.   End of event loop.
  461.   Print standard report.
  462.  
  463.                           EXERCISE 4.7
  464.                           ============
  465. Problem statement
  466. -----------------
  467.   A shop for watch repair is open from 10 am through 10 pm,
  468.   seven days a week. On an average week 25 faulty watches arrive
  469.   for repair and they may came even when the shop is closed. In
  470.   the last situation they are left in the "night" box. It takes 2
  471.   hours to repair a watch on the average. Renewed watches are
  472.   sent back to customers at the end of day (at 10 pm). What
  473.   should be the size of the night box and the shelves dedicated
  474.   for watches waiting for repair and those waiting for delivery?
  475.   Assume that work is continued as usual on a piece which has
  476.   been started before 10 pm no matter what the time is.
  477.   [Listing 8]
  478.  
  479. Programming tips
  480. ----------------
  481. * Different kinds of periods (such as the shop is opened and
  482.   closed) is modelled by an entity whose role is to set an
  483.   appropriate switch (open/close) at given times.
  484. * Define TRUE/FALSE in BASIC/C for better readability
  485.  
  486. Tutor SSS                                                 Page 10
  487.  
  488. Points to observe
  489. -----------------
  490. * When an event is scheduled, it is always made for the current
  491.   entity. Therefore, when SCHED(g,e,i) is called there MUST BE a
  492.   current entity. After the call that entity survives in the
  493.   calendar and there is no current entity in system. Hence, if
  494.   you SCHEDule another event (such as CLOSES, STARTA, etc) do not
  495.   call DISPOS. However, if you do not SCHEDule another event do
  496.   call DISPOS (as is done in subroutine box(), newday(), etc).
  497. * When an event has to arrive to ARRIVL event it must be CREATed
  498.   and not SCHEDuled.
  499.  
  500. Constants
  501. ---------
  502.   ARRIVL(1) Event code of new arrival to the system
  503.   STARTA(2) Event code that a repair activity commences
  504.   ENDACT(3) Event code that repair activity is finished
  505.   NEXTAC(4) Event code where it is decided what to do with the
  506.             current entity
  507.   STRTDY(5) Event code for opening the shop at the STaRT of DaY
  508.   CLOSES(0) Identity code meaning that entity closes the shop
  509.   WATCH(1)  Identity code meaning that entity is a watch
  510.   FALSE     In case that language does not have FALSE/TRUE
  511.   TRUE      (the case in C & BASIC) define them.
  512.  
  513. Variables
  514. ---------
  515.   ecode = current value of event code
  516.   opens = true if and only if shop is open
  517.   repars= true if and only if workman is in middle of repair
  518.   n     = number of watches in the night box.
  519.   r     = number of watches on shelf waiting for repair
  520.   d     = number of watches waiting for delivery
  521.   inter = mean interarrival time of watches
  522.   rept  = mean repair time
  523.  
  524. Types of entities (identities)
  525. ------------------------------
  526.   0: entity which closes the shop at end of day
  527.   1: watch
  528.  
  529. Statistics
  530. ----------
  531.   1. for n - time persistent
  532.   2. for r - time persistent
  533.   3. for d - time persistent
  534.  
  535. Subroutines
  536. -----------
  537.   prime()   Initializes statistics, sets simulation end at 10
  538.             time units, creates the first watch arrival and the
  539.             first arrival of closing the shop and initializes
  540.             variables.
  541.  
  542. Tutor SSS                                                 Page 11
  543.  
  544.   clshop()  The code for closing shop: clears opens switch (e.i.,
  545.             signalling that shop is closed) and d (e.i. all the
  546.             watches waiting for delivery are taken) and updates
  547.             d's statistic.
  548.   box()     The code for leaving a watch in the night box: kill
  549.             the entity by DISPOS, increase the number of watches
  550.             in the night box and register their number for
  551.             statistic #1.
  552.   newday()  CREATE an event which closes the shop in another 1/2
  553.             day, kill current event, signal that shop is open
  554.             and that workman is idle, add contents of night box
  555.             (n) to watches waiting for repair (r) and update
  556.             their respective statistics.
  557.  
  558. Pseudo code of main routine
  559. ---------------------------
  560.   Initialize.
  561.   The event loop:
  562.     A new entity arrives (ARRIVL):
  563.       If it is a watch: CREATE the next watch's arrival at a
  564.         random time from now (EX(inter)) and send entity to NEXT
  565.         ACtivity.
  566.       Otherwise (i.e. it is an entity causing the shop to close):
  567.         SCHEDule opening the shop in another 1/2 day from now and
  568.         perform the code associated with closing the shop
  569.         (clshop()).
  570.     NEXT ACtivity (NEXTAC):
  571.       If shop is open: increase number of watches on shelf
  572.         waiting for repair and register their number for time
  573.         persistent statistic. If worker is repairing, DISPOSe
  574.         entity, otherwise (e.i., worker is free) send entity to
  575.         START of Activity to begin repair.
  576.       Else (e.i., if shop is closed): perform code in subroutine
  577.         box().
  578.     START of Activity (STARTA):
  579.       SCHEDule the finish of repair activity for a random time
  580.         from now (EX(rept)), decrease number watches waiting for
  581.         repair, register their new number in statistic #2, and
  582.         signal that workman is repairing.
  583.     END of ACTivity (ENDACT):
  584.       Increase number of watches waiting for delivery (e.i.,
  585.         after repair but still in shop) and register them in
  586.         statistic #3. If there are more watches waiting for
  587.         repair, start the repairing cycle by sending current
  588.         entity to START of Activiy, otherwise kill current entity
  589.         and set the workman idle (e.i., not repairing).
  590.     STaRT of a new DaY (STRTDY):
  591.       Perform the code in newday().
  592.   End of event loop.
  593.   Print standard report.
  594.  
  595. Tutor SSS                                                 Page 12
  596.  
  597.                           EXERCISE 5.1
  598.                           ============
  599. Problem statement
  600. -----------------
  601.   What is the time that passes between leaving a watch in the
  602.   shop and its delivery in 4.7 ? [Listing 9]
  603.  
  604. New simulation concepts
  605. -----------------------
  606. * Attribute: A numerical characteristic carried by each entity
  607.   such as time of arrival
  608. * Queue: A buffer where entities are waiting.
  609.  
  610. New SSS routines
  611. ----------------
  612.   INIQUE(q,b,s) Initializes q queues, b attributes, s statistics
  613.   SETA(n,v)     Sets attribute n of current entity to v
  614.   A(n)          Returns the n-th attribute of current entity
  615.   QUEUE(m,0)    Enters the current entity to queue m
  616.   REMVFQ(m,r)   Removes r-th entity from queue m
  617.   NQ(m)         Returns the number of entities in queue m
  618.  
  619. Programming tips
  620. ----------------
  621. * When necessary to empty a queue use the code similar to the
  622.   loop in subroutine clshp()
  623. * When necessary to move all the entities in a queue to another
  624.   use code similar to the loop in subroutine newday()
  625.  
  626. Points to observe
  627. -----------------
  628. * DISPOSe WATCHs only when they really leave the shop, as
  629.   otherwise their arrival time (carried by them as attribute #1)
  630.   is lost.
  631. * Incrementing/decrementing of entities in queues is done
  632.   automatically by QUEUE/REMVFQ
  633. * The time persistent statistic for queue size is automatically
  634.   updated and printed out by SUMRY
  635.  
  636. Constants
  637. ---------
  638.   ARRIVL(1) Event code of new arrival to the system
  639.   STARTA(2) Event code that a repair activity commences
  640.   ENDACT(3) Event code that repair activity is finished
  641.   NEXTAC(4) Event code where it is decided what to do with the
  642.             current entity
  643.   STRTDY(5) Event code for opening the shop at the STaRT of DaY
  644.   CLOSES(0) Identity code meaning that entity closes the shop
  645.   WATCH(1)  Identity code meaning that entity is a watch
  646.   FALSE     In case that language does not have FALSE/TRUE
  647.   TRUE      (the case in C & BASIC) define them.
  648.  
  649. Tutor SSS                                                 Page 13
  650.  
  651. Variables
  652. ---------
  653.   ecode = current value of event code
  654.   opens = true if and only if shop is open
  655.   repars= true if and only if workman is in middle of repair
  656.   inter = mean interarrival time of watches
  657.   rept  = mean repair time
  658.  
  659. Types of entities (identities)
  660. ------------------------------
  661.   0: entity which closes the shop at end of day
  662.   1: watch
  663.  
  664. Queues
  665. ------
  666.   1. Watches in the night box
  667.   2. Watches waiting for repair in the shop
  668.   3. Watches waiting for delivery
  669.  
  670. Attribute
  671. ---------
  672.   1. Time of watch's arrival
  673.  
  674. Statistic
  675. ---------
  676.   1. Sojourn time of the watch
  677.  
  678. Subroutines
  679. -----------
  680.   prime()   Initializes queues, attribute, statistics, sets
  681.             simulation end at 10 time units, creates the first
  682.             watch arrival and the first arrival of closing the
  683.             shop and initializes variables.
  684.   clshop()  The code for closing shop: clears opens switch (e.i.,
  685.             signalling that shop is closed) and empties queue #3,
  686.             registering the entity's sojourn times.
  687.   newday()  CREATE an event which closes the shop in another 1/2
  688.             day, kill current event (CLOSES), signal that shop is open
  689.             and that workman is idle and move all the contents of
  690.             night box (queue #1) to queue #2.
  691.  
  692. Pseudo code of main routine
  693. ---------------------------
  694.   Initialize.
  695.   The event loop:
  696.     A new entity arrives (ARRIVL):
  697.       If it is a watch: CREATE the next watch's arrival at a
  698.         random time from now (EX(inter)), mark the arrival time
  699.         in 1st attribute and send entity to NEXT ACtivity.
  700.       Otherwise (i.e. it is an entity causing the shop to close):
  701.         SCHEDule opening the shop in another 1/2 day from now and
  702.         perform the code associated with closing the shop
  703.         (clshop()).
  704.  
  705. Tutor SSS                                                 Page 14
  706.  
  707.     NEXT ACtivity (NEXTAC):
  708.       If shop is open: if workmen is busy put entity (WATCH) to
  709.         queue #2 otherwise (e.i., worker is free) send entity to
  710.         START of Activity to begin repair.
  711.       Otherwise:(e.i., if shop is closed): put entity (WATCH) to
  712.         queue #1.
  713.     START of Activity (STARTA):
  714.       SCHEDule the finish of repair activity for a random time
  715.       from now (EX(rept)) and signal that workman is repairing.
  716.     END of ACTivity (ENDACT):
  717.       Put the entity (WATCH) to queue #3. If there are more
  718.         watches waiting for repair (e.i. queue #2 is not empty)
  719.         remove the first entity (WATCH) from queue #2 and "send"
  720.         it to STARTA, otherwise set the workman idle (e.i., not
  721.         repairing).
  722.     STaRT of a new DaY (STRTDY):
  723.       Perform the code in newday().
  724.   End of event loop.
  725.   Print standard report.
  726.  
  727.                           EXERCISE 5.5
  728.                           ============
  729. Problem statement
  730. -----------------
  731.   A station provides service to customers who arrive randomly
  732.   with an arrival rate of 1 per hour. Each customer requires a
  733.   normally distributed service time the mean of which is 40
  734.   minutes and the standard deviation of which is 10 minutes.
  735.   Customers are reimbursed for the time that they are in the
  736.   system. The payment p is such that (p-1) is exponentially
  737.   distributed with mean of $2 per hour. What is the average
  738.   payment to a customer? [Listing 10]
  739.  
  740. Programming tip
  741. ---------------
  742.   Identity code can be a counter of arrived entities, then each
  743.   entity can be tracked by its unique IDE()
  744.  
  745. Point to observe
  746. ----------------
  747.   Program is same for any number of identical servers.
  748.  
  749. Constants
  750. ---------
  751.   ARRIVL(1) Event code of new arrival to the system
  752.   STARTA(2) Event code that a service activity commences
  753.   ENDACT(3) Event code that service activity is finished
  754.   NEXTAC(4) Event code where it is decided what to do with the
  755.             current entity
  756.  
  757. Variables
  758. ---------
  759.   id     = identity code of previously CREATEd entity (counter)
  760.   server = number of free servers
  761.   ecode  = present value of event code
  762.  
  763. Tutor SSS                                                 Page 15
  764.  
  765. Queue
  766. -----
  767.   1. Waiting line in front of the service station
  768.  
  769. Attribute
  770. ---------
  771.   1. Arrival time
  772.  
  773. Statistics
  774. ----------
  775.   1. Cost associated with customer's time in service station
  776.  
  777. Subroutine
  778. ----------
  779.   prime()   Initializes queue, attribute, statistic, sets
  780.             simulation end at 24 time units, creates the first
  781.             customer arrival and initializes variables.
  782.  
  783. Pseudo code of main routine
  784. ---------------------------
  785.   Initialize.
  786.   The event loop:
  787.     A new entity arrives (ARRIVL):
  788.       Increase the entity counter and CREATE next entity in EX(1)
  789.         time from now. Note arrival time in attribute #1 and send
  790.         the customer to NEXT ACtivity.
  791.     NEXT ACtivity (NEXTAC):
  792.       If there is a free server send the customer to START
  793.         service Activity, otherwise put customer to waiting line
  794.         (queue #1).
  795.     START of service Activity (STARTA):
  796.       SCHEDule the end of service a random time from now from the
  797.         normal distribution. Decrement the number of free servers.
  798.     END of service ACTivity (ENDACT):
  799.       Register the cost associated with the service, DISPOSe the
  800.         current customer and increase the number of free servers.
  801.         If there is a customer in the waiting line (e.i., if
  802.         NQ(1) is positive), take the first waiting customer and
  803.         START a service Activity.
  804.   End of event loop.
  805.   Print standard report.
  806.  
  807. Tutor SSS                                                 Page 16
  808.  
  809.                           EXERCISE 5.6
  810.                           ============
  811. Problem statement
  812. -----------------
  813.   In a workshop there are three workstations in tandem, the
  814.   first gets the parts from another department and the others get
  815.   them from the previous station. After each station there is a
  816.   quality control station which may reject a defective part for
  817.   rework at the same station (assume it is possible to rework the
  818.   parts in a countless number of times if necessary). The
  819.   probabilities of a defective part are 0.3, 0.2, 0.1 at stations
  820.   # 1, 2, 3 respectively. The time for rework is half of the time
  821.   that the part underwent at the same station before. There are
  822.   finite buffers of 5 parts in front of each station except the
  823.   first. If they are full no more parts can be started in the
  824.   previous station. The arrival of new parts from previous
  825.   department is random with average of 2 parts per hour. The time
  826.   of working at each station is normally distributed with mean of
  827.   15 minutes and standard deviation of 3 minutes. What is the
  828.   portion of time that the stations make productive work, thus
  829.   neither waiting nor reworking? [Listing 11]
  830.  
  831. New simulation concept
  832. ----------------------
  833. * A station is blocked if it cannot work because the buffers in
  834.   front of it are full.
  835.  
  836. Programming tips
  837. ----------------
  838. * Use identity to mean which station serves the part and how many
  839.   reworks has been done to it. Therefore let identity be
  840.   4*rewkn + (statn - 1). This is a way to compress information
  841.   when necessary.
  842. * Identity code may have different meanings at ARRIVL and
  843.   elsewhere because no entity can go back to arrival event once
  844.   it became current.
  845. * Debug of complex logic can be performed by selective printouts
  846.   at strategic places governed by a debug flag. This can be left
  847.   in the final code (when the debug flag is turned off) to
  848.   facilitate maintenance and code reuse. Note the role of
  849.   subroutine wait().
  850. * Utilize station indeces to simplify references to queues,
  851.   statistics, etc.
  852.  
  853. Points to observe
  854. -----------------
  855. * A message sent to a label is modelled by an entity carrying the
  856.   contents of massage as identity or attribute.
  857. * All the event labels serve as a generic model of any station
  858.   when the actual station is dealt through the station indeces.
  859. * Sending an entity to an event label by SCHED can be performed
  860.   from anywhere, also from a subroutine. Note that SCHED works
  861.   for an entity as a "nonlocal goto" (or "long jump").
  862.  
  863. Tutor SSS                                                 Page 17
  864.  
  865. * When a station stops being blocked, the "unblocking" action may
  866.   reverberate "upstream". Note how it is done in subroutine
  867.   unblk(i).
  868. * Although in FORTRAN a subroutine cannot call itself, but two
  869.   can call each other any times, which has the same effect
  870.   (recursion) - this happens with triggr(i) and unblk(i) below.
  871.  
  872. Constants
  873. ---------
  874.   ARRIVL(1) Event code of new arrival to the system
  875.   STARTA(2) Event code that a service activity commences
  876.   ENDACT(3) Event code that service activity is finished
  877.   NEXTAC(4) Event code where it is decided what to do with the
  878.             current entity
  879.   FINAL(3)  Index of final station
  880.   FALSE     In case that language does not have FALSE/TRUE
  881.   TRUE      (the case in C & BASIC) define them.
  882.  
  883. Variables
  884. ---------
  885.   ecode    = present value of event code
  886.   statn    = present index of station
  887.   rewkn    = rework counter at station statn (0 for first
  888.              processing at statn)
  889.   debugf   = debug flag
  890.   serial   = serial number of parts
  891.   busy[i]  = TRUE if station i is busy (working on a part)
  892.   block[i] = TRUE if station i is blocked
  893.   defect[i]= probability of founding a defective part after
  894.              station i.
  895.  
  896. Types of entities (identities)
  897. ------------------------------
  898.   At ARRIVL event:
  899.     0: part
  900.     i: massage that station i became unblocked
  901.   Elsewhere:
  902.     4*rewkn + (statn - 1): state of the part - rewkn times has
  903.       been reworked at station number statn.
  904.  
  905. Queues
  906. ------
  907.   i. Buffer in front of station i, i=1,2,3
  908.  
  909. Attributes
  910. ----------
  911.   1. working time
  912.   2. serial number
  913.  
  914. Statistics
  915. ----------
  916.   i. Proportion of useful working (working and neither reworking
  917.      or idle) of station i, i=1,2,3
  918.  
  919. Tutor SSS                                                 Page 18
  920.  
  921. Subroutines
  922. -----------
  923.   prime()   Initializes queue, attribute, statistic, sets
  924.             simulation end at 6 time units, creates the first
  925.             part arrival and initializes variables.
  926.   deciph(i) Decodes identity code (given as argument i) and
  927.             recovers statn and rewkn.
  928.   triggr(i) Triggers start of work for first part waiting in
  929.             buffer in front of station #i by removing the first
  930.             entity from queue #1 and sending it to NEXT Activity.
  931.             It also CREATEs a new entity (massage) that station
  932.             #(i - 1) may be stop being blocked if i > 1.
  933.   unblk(i)  Code called every time that station #i may stop being
  934.             blocked. It DISPOSes the entity (massage) and if #i
  935.             indeed has been blocked and can start working on a
  936.             waiting part in its buffer (queue #i is not empty and
  937.             the station is not busy) it starts working by calling
  938.             triggr(i). It also sets its state as being not
  939.             blocked.
  940.   wait()    Stops momentarily the running to enable to inspect
  941.             the output.
  942.  
  943. Pseudo code of main routine
  944. ---------------------------
  945.   Initialize.
  946.   The event loop:
  947.     A new entity arrives (ARRIVL):
  948.       If the new entity is a message that station IDE stopped
  949.         being blocked perform the code of subroutine unblk().
  950.       else (the new entity is a part from another department):
  951.         CREATE the arrival of next new part, set attributes and
  952.         send the part to NEXT Activity.
  953.     NEXT Activity (NEXTA):
  954.       Recover station and rework numbers (by deciph(IDE)).
  955.       If station is busy or blocked then place part to the
  956.         buffer,
  957.       else (neither busy nor blocked) send the part to START of
  958.         Activity event.
  959.     START of Activity (STARTA):
  960.       Recover station and rework numbers (by deciph(IDE)).
  961.       If this part is new for this station (rewkn = 0) register
  962.         it with statistic #statn.
  963.       Set station's state busy and SCHEDule and END of ACTivity
  964.         after processing time (kept in attribute #1).
  965.  
  966. Tutor SSS                                                 Page 19
  967.  
  968.     END of ACTivity (ENDACT):
  969.       Recover station and rework numbers (by deciph(IDE)).
  970.       Register that working is over at statistic #statn.
  971.       Set station's state not busy.
  972.       If part is not defective (which is random: if RA >
  973.         defect(statn)) then:
  974.         If this is the FINAL station, DISPOSe the part,
  975.         else set working time (random normal) for following
  976.           station in attribute #1 and send it to NEXT Activity.
  977.       Otherwise (if part is defective): set its new working time
  978.         as half of its last time (all is kept in attribute #1)
  979.         and SCHEDule it for a rework while noting in the identity
  980.         the updated rework number.
  981.       If there are more parts waiting for this station perform
  982.         the code in subroutine triggr for this station.
  983.   End of event loop.
  984.   Print standard report.
  985.  
  986.                           EXERCISE 6.1
  987.                           ============
  988. Problem statement
  989. -----------------
  990.   What is the average payment in 5.5 if the queue is ranked by
  991.   the ratio (hourly payment)/(service time) ? [Listing 12]
  992.  
  993. New simulation concept
  994. ----------------------
  995.   Queue discipline: a rule determining the ordering of entities
  996.   in the queue. May be one of: FIFO (first in first out -
  997.   default), LIFO (last in first out), BVF (big value first - ties
  998.   are broken by FIFO), SVF (small value first - ties are broken
  999.   by LIFO).
  1000.  
  1001. New SSS routines
  1002. ----------------
  1003.   SETQDC(m,d)  Sets discipline d in queue number #m
  1004.   QUEUE(m,p)   Enters current entity to queue m with priority p
  1005.  
  1006. Constants
  1007. ---------
  1008.   ARRIVL(1) Event code of new arrival to the system
  1009.   STARTA(2) Event code that a service activity commences
  1010.   ENDACT(3) Event code that service activity is finished
  1011.   NEXTAC(4) Event code where it is decided what to do with the
  1012.             current entity
  1013.  
  1014. Variables
  1015. ---------
  1016.   id     = identity code of previously CREATEd entity (counter)
  1017.   server = number of free servers
  1018.   ecode  = present value of event code
  1019.  
  1020. Tutor SSS                                                 Page 20
  1021.  
  1022. Queue
  1023. -----
  1024.   1. Waiting line in front of the service station
  1025.  
  1026. Attributes
  1027. ----------
  1028.   1. Arrival time
  1029.   2. Hourly payment
  1030.   3. Service time
  1031.  
  1032. Statistic
  1033. ---------
  1034.   1. Cost associated with customer's time in service station
  1035.  
  1036. Subroutine
  1037. ----------
  1038.   prime()   Initializes queue, attribute, statistic, sets
  1039.             simulation end at 24 time units, creates the first
  1040.             customer arrival, initializes variables and sets
  1041.             queue discipline to SVF.
  1042.  
  1043. Pseudo code of main routine
  1044. ---------------------------
  1045.   Initialize.
  1046.   The event loop:
  1047.     A new entity arrives (ARRIVL):
  1048.       Increase the entity counter and CREATE next entity in EX(1)
  1049.         time from now. Set all three attributes and send the
  1050.         customer to NEXT ACtivity.
  1051.     NEXT ACtivity (NEXTAC):
  1052.       If there is a free server send the customer to START
  1053.         service Activity, otherwise put customer to waiting line
  1054.         (queue #1) with priority which is the quotient
  1055.         (hourly payment)/(service time).
  1056.     START of service Activity (STARTA):
  1057.       SCHEDule the end of service a random time from now from the
  1058.         normal distribution. Decrement the number of free servers.
  1059.     END of service ACTivity (ENDACT):
  1060.       Register the cost associated with the service, DISPOSe the
  1061.         current customer and increase the number of free servers.
  1062.         If there is a customer in the waiting line (e.i.,
  1063.         if NQ(1) is positive), take the first waiting customer
  1064.         and START a service Activity.
  1065.   End of event loop.
  1066.   Print standard report.
  1067.  
  1068. Tutor SSS                                                 Page 21
  1069.  
  1070.                           EXERCISE 6.4
  1071.                           ============
  1072. Problem statement
  1073. -----------------
  1074.   In a repair shop there are two servers, both of whose service
  1075.   times are triangularly distributed with parameters 1,2,3 in
  1076.   hours. Customers may chose between ordinary and deluxe service,
  1077.   while the last one means that they are immediately served even
  1078.   if a server is busy with an ordinary customer. In the latter
  1079.   case the ordinary customer will wait and will be served
  1080.   immediately after all deluxe customers and his new service time
  1081.   will be whatever is left from his previous services. There is a
  1082.   single queue for ordinary customers who go to the first server
  1083.   who is free even if this means that he gets service from two
  1084.   different servers. Assume that customers arrive every two hours
  1085.   on the average and quarter of them chooses the deluxe service.
  1086.   How many interrupts will experience an average ordinary
  1087.   customer? [Listing 13]
  1088.  
  1089. New simulation concepts
  1090. -----------------------
  1091. * Preemptive priority: when entity preempts the resource (server)
  1092.   from entity of lower priority.
  1093. * Residual time: the time left from moment of preempting until
  1094.   end of service
  1095. * Rank: the place of entity in calendar or queue.
  1096.  
  1097. New SSS routines
  1098. ----------------
  1099.   NC()      Returns the number of scheduled items in calendar
  1100.   AIC(r,n)  Returns r-th entity's n-th attribute in calendar
  1101.   NEIC(r)   Returns the event code of r-th entity in calendar
  1102.   TIC(r)    Returns r-th enitity's time in calendar
  1103.   REMVFC(r) Removes r-th entity from calendar
  1104.  
  1105. Programming tips
  1106. ----------------
  1107. * To find an entity whose service is under way go over the
  1108.   calendar and try to find it there according to its event code
  1109.   (ENDACT) and its identity and/or attribute(s) - see preemp().
  1110. * To perform the above easier sometimes it is worthwhile to test
  1111.   the opposite condition.
  1112. * To place an entity at an arbitrary place in a queue (such as
  1113.   placing to first position in a FIFO queue) change queue
  1114.   discipline temporarily (to LIFO).
  1115. * Save the relevant parameter of the entity before removing it
  1116.   from calendar/queue
  1117.  
  1118. Point to observe
  1119. ----------------
  1120.   Physically one waiting line is represented by two queues if it
  1121.   makes easier to keep apart two kinds of entities (customers).
  1122.  
  1123. Tutor SSS                                                 Page 22
  1124.  
  1125. Constants
  1126. ---------
  1127.   ARRIVL(1) Event code of new arrival to the system
  1128.   STARTA(2) Event code that a service activity commences
  1129.   ENDACT(3) Event code that service activity is finished
  1130.   NEXTAC(4) Event code where it is decided what to do with the
  1131.             current entity
  1132.   ORDNRY(0) Identity code for an ordinary customer
  1133.   DELUX(1)  Identity code for a deluxe customer
  1134.  
  1135. Variables
  1136. ---------
  1137.   id     = identity code of previously CREATEd entity (counter)
  1138.   server = number of free servers
  1139.   ecode  = present value of event code
  1140.   remt   = residual time (should be saved prior to REMVFC!)
  1141.  
  1142. Queues
  1143. ------
  1144.   1. for ordinary customers
  1145.   2. for deluxe customers
  1146.  
  1147. Attributes
  1148. ----------
  1149.   1. number of times that an ordinary customer is interrupted in
  1150.      middle of service.
  1151.   2. (remaining)service time
  1152.   3. type: deluxe(1)/ordinary(0)
  1153.  
  1154. Statistic
  1155. ---------
  1156.   1. Interrupts in middle of service for ordinary customers A(1)
  1157.  
  1158. Subroutines
  1159. -----------
  1160.   prime()   Initializes queue, attribute, statistic, sets
  1161.             simulation end at 60 time units, creates the first
  1162.             customer arrival and initializes variables.
  1163.   preemp()  Current entity tries to preempt an ORDiNaRY entity,
  1164.             whose rank in calendar is i. If such entity is found
  1165.             then it is placed to QUEUE(1) with its remaining
  1166.             service time, remt, in A(2) and current one STARTs
  1167.             Activity of being served. Otherwise current entity is
  1168.             placed to QUEUE(2).
  1169.  
  1170. Pseudo code of preemp()
  1171. -----------------------
  1172.   Place present entity (must be of deluxe type) to queue #2.
  1173.   Go over all entities in calendar with event codes ENDACT and
  1174.     try to find an ORDNRY customer. Let its rank be i if found
  1175.     while i = NC + 1 if not found.
  1176.   If found (i <= NC) then:
  1177.     note the residual time in remt, remove it from calendar,
  1178.     update its two first attributes, place it as first in queue
  1179.     #1, remove the waiting deluxe customer from queue #2 and
  1180.     send to START of Activity.
  1181.  
  1182. Tutor SSS                                                 Page 23
  1183.  
  1184. Pseudo code of main routine
  1185. ---------------------------
  1186.   Initialize.
  1187.   The event loop:
  1188.     A new entity arrives (ARRIVL):
  1189.       Increase the entity counter, CREATE next entity in EX(2)
  1190.         time from now, set all the three attributes and send the
  1191.         customer to NEXT ACtivity.
  1192.     NEXT ACtivity (NEXTAC):
  1193.       If there is an available server (server > 0) send entity
  1194.         (customer) to START Activity.
  1195.       If all the servers are busy and the current customer is of
  1196.         deluxe type attempt a preempting in subroutine preemp(),
  1197.       otherwise (e.i., if type is ordinary) place customer to
  1198.         queue #1.
  1199.     START of service Activity (STARTA):
  1200.       SCHEDule the end of service A(2) time from now. Decrement
  1201.         the number of free servers.
  1202.     END of service ACTivity (ENDACT):
  1203.       Register the number of interruptions for an ordinary
  1204.         customer, DISPOSe the current customer and increase the
  1205.         number of free servers. If there is a waiting deluxe
  1206.         customer (e.i., if NQ(2) is positive), take the first
  1207.         waiting customer and START a service Activity.
  1208.         Otherwise, if there is a waiting ordinary customer (e.i.,
  1209.         if NQ(1) is positive), take the first waiting customer
  1210.         and START a service Activity.
  1211.   End of event loop.
  1212.   Print standard report.
  1213.  
  1214.                           EXERCISE 7.1
  1215.                           ============
  1216. Problem statement
  1217. -----------------
  1218.   Assume that in problem 6.4 there are two different queues in
  1219.   front of the servers and each customer has to decide to which
  1220.   waiting line to join. Once in the queue, no customer may change
  1221.   mind. The customer joins the line with fewer people and if an
  1222.   ordinary customer is preempted he or she should return to the
  1223.   same server that they started with. Assume that deluxe
  1224.   customers cannot differentiate between ordinary and deluxe
  1225.   types, and the queue length seems to them accordingly, if they
  1226.   cannot be served. [Listing 14]
  1227.  
  1228. New SSS routines
  1229. ----------------
  1230.   IDIC(r)   Returns the id of r-th entity in calendar
  1231.   SETIDE(i) Sets identity of current entity to i
  1232.  
  1233. Programming tip
  1234. ---------------
  1235.   Make queue and/or resource index function of identity code
  1236.   and/or attribute(s), if necessary through functions - see
  1237.   shortr() and sindex().
  1238.  
  1239. Tutor SSS                                                 Page 24
  1240.  
  1241. Constants
  1242. ---------
  1243.   ARRIVL(1) Event code of new arrival to the system
  1244.   STARTA(2) Event code that a service activity commences
  1245.   ENDACT(3) Event code that service activity is finished
  1246.   NEXTAC(4) Event code where it is decided what to do with the
  1247.             current entity
  1248.   ORD1(1)   Identity code for an ordinary customer in first line
  1249.   ORD2(2)   Identity code for an ordinary customer in second line
  1250.   DELUX1(3) Identity code for a deluxe customer in first line
  1251.   DELUX2(4) Identity code for a deluxe customer in second line
  1252.  
  1253. Variables
  1254. ---------
  1255.   server[i] = number of free servers for line #i
  1256.   ecode     = present value of event code
  1257.   remt      = residual time (should be saved prior to REMVFC!)
  1258.   preide    = identity of interrupted customer (ditto to QUEUE!)
  1259.  
  1260. Types of entities (identities)
  1261. ------------------------------
  1262.   1. ordinary customer in first line
  1263.   2. ordinary customer in second line
  1264.   3. deluxe customer in first line
  1265.   4. deluxe customer in second line
  1266.  
  1267. Queues
  1268. ------
  1269.   1. ordinary customer in first line
  1270.   2. ordinary customer in second line
  1271.   3. deluxe customer in first line
  1272.   4. deluxe customer in second line
  1273.   5. temporary place for deluxe
  1274.  
  1275. Attributes
  1276. ----------
  1277.   1. number of times that an ordinary customer is interrupted in
  1278.      middle of service.
  1279.   2. (remaining)service time
  1280.  
  1281. Statistic
  1282. ---------
  1283.   1. Interrupts in middle of service for ordinary customers A(1)
  1284.  
  1285. Subroutines
  1286. -----------
  1287.   prime()   Initializes queue, attribute, statistic, sets
  1288.             simulation end at 60 time units, creates the first
  1289.             customer arrival and initializes variables.
  1290.   sindex()  Returns the server index according to IDE.
  1291.   shortr()  For an ordinary entity returns 1 or 2, while for a
  1292.             deluxe entity returns 3 or 4, depending where the
  1293.             queue is shorter. IDE is also updated with the
  1294.             returned value.
  1295.  
  1296. Tutor SSS                                                 Page 25
  1297.  
  1298.   preemp()  Current entity tries to preempt an ORDiNaRY entity,
  1299.             whose rank in calendar is i. If such entity is found
  1300.             then it is placed to QUEUE(IDE) with its remaining
  1301.             service time, remt, in A(2) and current one STARTs
  1302.             Activity of being served. Otherwise current entity is
  1303.             placed to QUEUE(shortr) - a revised form of
  1304.             subroutine preemp() from 6.4
  1305.  
  1306. Pseudo code of main routine
  1307. ---------------------------
  1308.   Initialize.
  1309.   The event loop:
  1310.     A new entity arrives (ARRIVL):
  1311.       CREATE next entity in EX(2) time from now, set all the
  1312.         both attributes and send the customer to NEXT ACtivity.
  1313.     NEXT ACtivity (NEXTAC):
  1314.       If there is an available server (server(i) > 0) send entity
  1315.         (customer) to START Activity with appropriate identity.
  1316.       If all the servers are busy and the current customer is of
  1317.         deluxe type attempt a preempting in subroutine preemp(),
  1318.       otherwise (e.i., if type is ordinary) place customer to
  1319.         shorter queue appropriate to the identity.
  1320.     START of service Activity (STARTA):
  1321.       SCHEDule the end of service A(2) time from now. Decrement
  1322.         the number of free servers.
  1323.     END of service ACTivity (ENDACT):
  1324.       Register the number of interruptions for an ordinary
  1325.         customer, DISPOSe the current customer and increase the
  1326.         number of free servers. If there is a waiting deluxe
  1327.         customer (e.i., if NQ(s + 2) is positive), take the first
  1328.         waiting customer and START a service Activity. Otherwise,
  1329.         if there is a waiting ordinary customer (e.i., if NQ(s)
  1330.         is positive), take the first waiting customer and START
  1331.         a service Activity.
  1332.   End of event loop.
  1333.   Print standard report.
  1334.  
  1335.                           EXERCISE 7.2
  1336.                           ============
  1337. Problem statement
  1338. -----------------
  1339.   In a station boxes are assembled from the main part and the
  1340.   cover, both has to be of the same color. There are four colors:
  1341.   white (35%), blue (15%), red (30%) and yellow (20%). The two
  1342.   parts arrive from two different departments at random at the
  1343.   rate of 5 parts per hour. The assembly takes a normally
  1344.   distributed time with mean of 10 minutes and standard deviation
  1345.   of 2 minutes. What should be the buffer sizes of the two parts?
  1346.   [Listing 15]
  1347.  
  1348. New simulation concept
  1349. ----------------------
  1350.   Matching: finding two or more entities in one or more queues
  1351.   according to same or opposing identity and/or attribute(s).
  1352.  
  1353. Tutor SSS                                                 Page 26
  1354.  
  1355. New SSS routines
  1356. ----------------
  1357.   AIQ(m,r,n) Returns the r-th entity's n-th attribute in queue m
  1358.   NCEN()     Returns the number of current entities ( 1 or 0)
  1359.  
  1360. Programming tip
  1361. ---------------
  1362.   Trigger a matching by creating a special entity whose sole
  1363.   purpose is attempting to find a match. The triggering is caused
  1364.   by finishing working on the previous pair.
  1365.  
  1366. Point to observe
  1367. ----------------
  1368.   Having found a matching entity to a given one, one must be
  1369.   DISPOSed, while the other can represent both (this works well
  1370.   only if the pair is not split later)
  1371.  
  1372. Constants
  1373. ---------
  1374.   ARRIVL(1) Event code of new arrival to the system
  1375.   STARTA(2) Event code that a service activity commences
  1376.   ENDACT(3) Event code that service activity is finished
  1377.   NEXTAC(4) Event code where it is decided what to do with the
  1378.             current entity
  1379.   MATCH(5)  Event code that a matching main+cover in same color
  1380.             is sought.
  1381.   WHITE(1), BLUE(2), RED(3), YELLOW(4) Color values
  1382.   MAINP(1)  Identity code of main part
  1383.   COVER(2)  Identity code of cover
  1384.   MREQ(3)   Identity code of a matching request
  1385.  
  1386. Variables
  1387. ---------
  1388.   server = number of free servers
  1389.   ecode  = present value of event code
  1390.  
  1391. Types of entities (identities)
  1392. ------------------------------
  1393.   1.  main part
  1394.   2.  cover
  1395.   3.  matching request
  1396.  
  1397. Queues
  1398. ------
  1399.   1. for main parts
  1400.   2. for covers
  1401.  
  1402. Attributes
  1403. ----------
  1404.   1. color code
  1405.  
  1406. Tutor SSS                                                 Page 27
  1407.  
  1408. Subroutines
  1409. -----------
  1410.   prime()   Initializes queue, sets simulation end at 120 time
  1411.             units, creates the first arrivals for both parts and
  1412.             initializes free servers.
  1413.   find1()   At entry there is a current entity. It attempts to
  1414.             find an entity from the other queue with the same
  1415.             color. If attempt is successful, the present entity
  1416.             is DISPOSed and the matching entity becomes the
  1417.             present entity. Otherwise the entity on entry is
  1418.             placed in queue and at exit there is no current
  1419.             entity.
  1420.   find2()   At entry there is no current entity. It attempts to
  1421.             find two entities with same color from both queues.
  1422.             If attempt is successful, one is DISPOSed, the other
  1423.             becomes the current entity. Otherwise at exit there
  1424.             is no current entity.
  1425.   other()   Returns the identity of the "other part", e.i., for
  1426.             IDE = MAINP it returns COVER and vice versa.
  1427.  
  1428. Pseudo code of find1()
  1429. ----------------------
  1430.   Go over the "other" queue (e.i., if current entity is MAINP, go
  1431.     over queue of COVER and vice versa) and attempt to find there
  1432.     an entity with same color (same value of A(1)).
  1433.   If found (i <= queue length of "other" queue) DISPOSe current
  1434.     entity (as the "other" will represent it), remove the other
  1435.     entity from its queue and send it to START of Activity,
  1436.   otherwise (e.i., if none is found) place present entity on its
  1437.     queue.
  1438.  
  1439. Pseudo code of main routine
  1440. ---------------------------
  1441.   Initialize.
  1442.   The event loop:
  1443.     A new entity arrives (ARRIVL):
  1444.       If this is a matching request go to MATCH label,
  1445.       otherwise (it is either a main part or cover) CREATE the
  1446.         next arrival in EX(12) time from now, set the color code
  1447.         and send entity to NEXT ACtivity.
  1448.     NEXT ACtivity (NEXTAC):
  1449.       If a server is free and the "other" part's queue is not
  1450.         empty send the entity to MATCH,
  1451.       else place it to its queue.
  1452.     MATCHing two parts(MATCH) :
  1453.       If a request came because server became free (IDE = MREQ)
  1454.         then DISPOSe current entity (request) and try to find two
  1455.         matching parts from the queues (find2()),
  1456.       else (matching is to do for a new part which just has
  1457.         arrived) try to match another part to current entity
  1458.         (find1()).
  1459.       If matching is successful (there is a current entity:
  1460.         NCEN() > 0) send present entity to START of Activity.
  1461.  
  1462. Tutor SSS                                                 Page 28
  1463.  
  1464.     START of Activity (STARTA):
  1465.       SCHEDule the END of ACTivity a normally distributed random
  1466.         time from now. Decrement the number of free servers.
  1467.     END of service ACTivity (ENDACT):
  1468.       DISPOSe the current part and increase the number of free
  1469.         servers. If there are parts in both queues request a
  1470.         MATCHing by CREATE.
  1471.   End of event loop.
  1472.   Print standard report.
  1473.  
  1474.                           EXERCISE 8.4
  1475.                           ============
  1476. Problem statement
  1477. -----------------
  1478.   Change the service time in problem 5.5 to 54 minutes instead
  1479.   of 40. Assume that the station works nonstop and starts with an
  1480.   empty queue. What is the length of the warm-up period, or what
  1481.   is called the transient period? Use the queue size and its
  1482.   standard deviation as criteria. [Listing 16]
  1483.  
  1484. New simulation concept
  1485. ----------------------
  1486.   Transient period is the time for "warm up" from a "cold start".
  1487.   It may be estimated by inspecting a statistic (such as average
  1488.   queue size) over time (graphically, using a spreadsheet). Take
  1489.   it as the time from simulation start until that the statistic's
  1490.   value does not change appreciably
  1491.  
  1492. New SSS routines
  1493. ----------------
  1494.   QAVG(m) Returns average of queue # m
  1495.   QSTD(m) Returns standard deviation of queue # m
  1496.  
  1497. Points to observe
  1498. -----------------
  1499.   Output is to be processed by a spreadsheet program. Establish
  1500.   connection by writing a text file.
  1501.  
  1502. Constants
  1503. ---------
  1504.   ARRIVL(1) Event code of new arrival to the system
  1505.   STARTA(2) Event code that a service activity commences
  1506.   ENDACT(3) Event code that service activity is finished
  1507.   NEXTAC(4) Event code where it is decided what to do with the
  1508.             current entity
  1509.   TIMEL(150) Time limit on simulation
  1510.  
  1511. Variables
  1512. ---------
  1513.   n      = serial number of entities
  1514.   server = number of free servers
  1515.   ecode  = present value of event code
  1516.  
  1517. Tutor SSS                                                 Page 29
  1518.  
  1519. Queue
  1520. -----
  1521.   1. Waiting line in front of the service station
  1522.  
  1523. Subroutine
  1524. ----------
  1525.   prime()   Initializes queue, sets simulation end at TIMEL time
  1526.             units, creates the first customer arrival,
  1527.             initializes variables and opens output file.
  1528.  
  1529. Pseudo code of main routine
  1530. ---------------------------
  1531.   Initialize.
  1532.   The event loop:
  1533.     A new entity arrives (ARRIVL):
  1534.       Increase the entity counter and CREATE next entity in EX(1)
  1535.         time from now. Send the customer to NEXT ACtivity.
  1536.     NEXT ACtivity (NEXTAC):
  1537.       If there is a free server send the customer to START
  1538.         service Activity,
  1539.       otherwise put customer to waiting line (queue #1) and print
  1540.         to both screen and text file current value, average and
  1541.         standard deviation of queue size.
  1542.     START of service Activity (STARTA):
  1543.       SCHEDule the end of service a random time from now from the
  1544.       exponential distribution. Decrement the number of free
  1545.       servers.
  1546.     END of service ACTivity (ENDACT):
  1547.       DISPOSe the current customer and increase the number of
  1548.         free servers. If there is a customer in the waiting line
  1549.         (e.i., if NQ(1) is positive), take the first waiting
  1550.         customer, START a service Activity and print to both
  1551.         screen and text file current value, average and standard
  1552.         deviation of queue size.
  1553.   End of event loop.
  1554.  
  1555. Tutor SSS                                                 Page 30
  1556.  
  1557.                           EXERCISE 8.5
  1558.                           ============
  1559. Problem statement
  1560. -----------------
  1561.   Run four replicas of problem 8.4 for sufficient length and
  1562.   estimate the expected mean queue size from the results.
  1563.   [Listing 17]
  1564.  
  1565. New simulation concepts
  1566. -----------------------
  1567. * Run: simulation of a certain length. It refers to either the
  1568.   transient period or a sample. Runs may be subsequent and only
  1569.   technically separated.
  1570. * Cutting out transient period. To save runs take one transient
  1571.   period (call it run 0 - 120 time units) and SSIZE (= sample
  1572.   size = 4) consecutive runs not stopping simulations but only
  1573.   printing results and clearing statistics.
  1574. * Independent statistics can be obtained from runs of adequate
  1575.   length - take below as the transient period (TIMEL = 120).
  1576. * Control statistic technique. Estimate also a quantity that can
  1577.   be predicted theoretically (such as free fraction of server,
  1578.   0.9 in this exercise). Regression of statistic in question
  1579.   (queue) on size can reduce confidence interval.
  1580.  
  1581. New SSS routines
  1582. ----------------
  1583.   CLEARQ(m) Clears queue statistic of queue m, if m=0 clears all
  1584.   CLEARS(j) Clears statistic # j, if j=0 clears all j
  1585.   SAVG(j)   Returns average of variable # j
  1586.  
  1587. Programming tips
  1588. ----------------
  1589. * Always give signal from program that it works and is well
  1590.   especially for long simulations, but without messing the screen
  1591.   unnecessarily - see signal or print T;:locate,1 in BASIC
  1592. * To perform the above in a compiler not having subroutines for
  1593.   managing the screen (such as FORTRAN) use DOS' ANSI.SYS (take
  1594.   care to include it in file CONFIG.SYS)
  1595.  
  1596. Constants
  1597. ---------
  1598.   ARRIVL(1) Event code of new arrival to the system
  1599.   STARTA(2) Event code that a service activity commences
  1600.   ENDACT(3) Event code that service activity is finished
  1601.   NEXTAC(4) Event code where it is decided what to do with the
  1602.             current entity
  1603.   REPORT(5) Event code of reporting
  1604.   REPTME(-1) Identity code of a reporting event
  1605.   TIMEL(120) Length of each run
  1606.   SSIZE(4)  Sample size (number of runs except the warmup)
  1607.  
  1608. Tutor SSS                                                 Page 31
  1609.  
  1610. Variables
  1611. ---------
  1612.   n      = entity counter
  1613.   countr = run's counter
  1614.   server = number of free servers
  1615.   ecode  = present value of event code
  1616.  
  1617. Types of entities (identities)
  1618. ------------------------------
  1619.   -1 entity at end of transient period and each of the SSIZE
  1620.      runs
  1621.   n ( >= 0 ) customer
  1622.  
  1623. Queue
  1624. -----
  1625.   1. Waiting line in front of the service station
  1626.  
  1627. Attribute
  1628. ---------
  1629.   1. Service time
  1630.  
  1631. Statistic
  1632. ---------
  1633.   1. Free fraction of server - time persistent
  1634.  
  1635. Subroutines
  1636. -----------
  1637.   signal()  Writes massage always at the same place on screen.
  1638.   prime()   Initializes queue, sets simulation end at TIMEL time
  1639.             units, creates the first customer arrival and
  1640.             initializes variables.
  1641.  
  1642. Pseudo code of main routine
  1643. ---------------------------
  1644.   Initialize.
  1645.   The event loop:
  1646.     A new entity arrives (ARRIVL):
  1647.       If entity is end of a run (REPTIME) send it to REPORT event,
  1648.       otherwise increase the entity counter, set random service
  1649.         time from exponential distribution in attribute #1 and
  1650.         CREATE next entity in EX(1) time from now. Write state of
  1651.         simulation on screen and send the customer to NEXT
  1652.         ACtivity.
  1653.     NEXT ACtivity (NEXTAC):
  1654.       If there is a free server send the customer to START
  1655.         service Activity,
  1656.       otherwise put customer to waiting line (queue #1).
  1657.     START of service Activity (STARTA):
  1658.       SCHEDule the end of service A(1) time from now from the
  1659.         exponential distribution. Decrement the number of free
  1660.         servers.
  1661.  
  1662. Tutor SSS                                                 Page 32
  1663.  
  1664.     END of service ACTivity (ENDACT):
  1665.       DISPOSe the current customer and increase the number of
  1666.         free servers. If there is a customer in the waiting line
  1667.         (e.i., if NQ(1) is positive), take the first waiting
  1668.         customer and START a service Activity.
  1669.     REPORT:
  1670.       SCHEDule next REPORTing in time TIMEL from now, print for
  1671.         each sample (except for transient period) average queue
  1672.         length and free fraction of server, clear statistics,
  1673.         advance run counter. At end of final (SSIZE) run finish
  1674.         simulation.
  1675.   End of event loop.
  1676.  
  1677.                           EXERCISE 8.7
  1678.                           ============
  1679. Problem statement
  1680. -----------------
  1681.   Try to reduce the variance for problem 8.5 by means of
  1682.   antithetic variables. [Listing 18]
  1683.  
  1684. New simulation concepts
  1685. -----------------------
  1686. * Random stream: the sequence of random variates denoted as X<1>,
  1687.   X<2>,...
  1688. * Seed: the first number of the stream, X<1>. Given X<1>, the
  1689.   whole stream is fixed a sequence (e.i., not really random, only
  1690.   appears as random, called pseudo random).
  1691. * Antithetic variable: X and Y are antithetic for a probability
  1692.   distribution with cumulative function F if F(X) = 1 - F(Y).
  1693.   Rerun of the same program with an antithetic stream reduces the
  1694.   estimates' variances.
  1695.  
  1696. New SSS routines
  1697. ----------------
  1698.   SETANT(y)  Sets (y > 0)/clears (y = 0) antithetic variables
  1699.   SETSEE(x)  Sets seed to value x (x is odd positive integer)
  1700.  
  1701. Programming tip
  1702. ---------------
  1703.   Use SIMEND(0) and an entity counter to stop simulation after a
  1704.   given number of customers.
  1705.  
  1706. Points to observe
  1707. -----------------
  1708. * Care should be exercised that the two streams should be "in
  1709.   phase" EXACTLY (e.i., if X<m> is the the interarrival time
  1710.   between customers no. i and i+1, then Y<m> should have the SAME
  1711.   significance).
  1712. * To satisfy the above a run will consists of a fixed number of
  1713.   customers rather than simulated time and service time is
  1714.   determined at arrival (which occurs for both stream at the
  1715.   same sequence) rather than at start of service (which is a
  1716.   function of the specific stream!). Because of this A(1) is
  1717.   needed to hold service time until service actually starts.
  1718.  
  1719. Tutor SSS                                                 Page 33
  1720.  
  1721. Constants
  1722. ---------
  1723.   ARRIVL(1) Event code of new arrival to the system
  1724.   STARTA(2) Event code that a service activity commences
  1725.   ENDACT(3) Event code that service activity is finished
  1726.   NEXTAC(4) Event code where it is decided what to do with the
  1727.             current entity
  1728.   TIMEL(120) Number of customers per run
  1729.  
  1730. Variables
  1731. ---------
  1732.   n      = entity counter
  1733.   countr = counter of runs (0 = first run)
  1734.   server = number of free servers
  1735.   ecode  = present value of event code
  1736.   t0     = simulated time that present run started
  1737.  
  1738. Queue
  1739. -----
  1740.   1. Waiting line in front of the service station
  1741.   2. "Shelter" for an entity to save it from erasing by resque().
  1742.      The entity is essential to restart simulation (which is
  1743.      generally performed by CREATE inside prime()).
  1744.  
  1745. Attribute
  1746. ---------
  1747.   1. Service time
  1748.  
  1749. Statistic
  1750. ---------
  1751.   1. Free fraction of server - time persistent
  1752.  
  1753. Subroutines
  1754. -----------
  1755.   signal()  Writes massage always at the same place on screen.
  1756.   prime()   Initializes queue, sets simulation end at TIMEL time
  1757.             units, creates the first customer arrival and
  1758.             initializes variables.
  1759.   resque()  Resets the system: clears all statistics and queues
  1760.             except the queue(s) holding entity(ies) which restarts
  1761.             simulation.
  1762.   endper()  Called at beginning/end of each run. Except for end
  1763.             of transient periods it prints statistics. In the
  1764.             beginning of transient periods it initializes random
  1765.             stream by calling SETSEE & SETANT and resets server
  1766.             and simulation by calling resque(). In any event it
  1767.             clears statistics, advances run counter and saves
  1768.             simulated time of run start in t0.
  1769.  
  1770. Tutor SSS                                                 Page 34
  1771.  
  1772. Pseudo code of main routine
  1773. ---------------------------
  1774.   Initialize.
  1775.   The event loop:
  1776.     A new entity arrives (ARRIVL):
  1777.       If current entity is the last in this run call subroutine
  1778.         endper().
  1779.       Increase the entity counter, set random service time from
  1780.         exponential distribution in attribute #1 and CREATE next
  1781.         entity in EX(1) time from now. Write state of simulation
  1782.         on screen and send the customer to NEXT ACtivity.
  1783.     NEXT ACtivity (NEXTAC):
  1784.       If there is a free server send the customer to START
  1785.         service Activity,
  1786.       otherwise put customer to waiting line (queue #1).
  1787.     START of service Activity (STARTA):
  1788.       SCHEDule the end of service A(1) time from now from the
  1789.         exponential distribution. Decrement the number of free
  1790.         servers.
  1791.     END of service ACTivity (ENDACT):
  1792.       DISPOSe the current customer and increase the number of
  1793.         free servers. Register free servers for statistic #1. If
  1794.         there is a customer in the waiting line (e.i., if NQ(1)
  1795.         is positive), take the first waiting customer and START
  1796.         a service Activity.
  1797.   End of event loop.
  1798.  
  1799. Tutor SSS                                                 Page 35
  1800.  
  1801.                          INDEX OF TUTOR
  1802.                          ==============
  1803.  
  1804.           The number x.y refers to the exercise number
  1805.  
  1806. A ...  ...  ...  ...  ... 5.1       NQ ..  ...  ...  ...  ... 5.1
  1807. AIC .  ...  ...  ...  ... 6.4       periodic events  ...  ... 4.7
  1808. AIQ .  ...  ...  ...  ... 7.2       preemptive priority   ... 6.4
  1809. antithetic variables  ... 8.7       priority .  ...  ...  ... 6.1
  1810. ANSI.SYS .  ...  ...  ... 8.5       QAVG   ...  ...  ...  ... 8.4
  1811. attribute   ...  ...  ... 5.1       QSTD   ...  ...  ...  ... 8.4
  1812. blocked stations ...  ... 5.6       QUEUE  ...  ...  ...  5.1,6.1
  1813. calendar .  ...  ...  ... 4.3       RA ..  ...  ...  ...  ... 2.6
  1814. CLEARQ ...  ...  ...  ... 8.5       rank   ...  ...  ...  ... 6.4
  1815. CLEARS ...  ...  ...  ... 8.5       recursion   ...  ...  ... 5.6
  1816. control statistic ..  ... 8.5       REMVFC ...  ...  ...  ... 6.4
  1817. CREATE ...  ...  ...  ... 4.3       REMVFQ ...  ...  ...  ... 5.1
  1818. current entity   ...  ... 4.3       RN ..  ...  ...  ...  ... 2.6
  1819. cycle time  ...  ...  ... 2.9       run .  ...  ...  ...  ... 8.5
  1820. debug  ...  ...  ...  ... 5.6       SAVG   ...  ...  ...  ... 8.5
  1821. discipline  ...  ...  ... 6.1       SCHED  ...  ...  ...  ... 4.3
  1822. DISPOS ...  ...  ...  ... 4.3       seed   ...  ...  ...  ... 8.7
  1823. entity ...  ...  ...  ... 4.3       SETA   ...  ...  ...  ... 5.1
  1824. event  ...  ...  ...  ... 4.3       SETANT ...  ...  ...  ... 8.7
  1825. event code  ...  ...  ... 4.3       SETIDE ...  ...  ...  ... 7.1
  1826. event loop  ...  ...  ... 4.3       SETQDC ...  ...  ...  ... 6.1
  1827. EX ..  ...  ...  ...  ... 2.1       SETSEE ...  ...  ...  ... 8.7
  1828. goto for an entity .  4.3,5.6       SETT   ...  ...  ...  ... 3.1
  1829. IDE .  ...  ...  ...  ... 4.1       SIMEND ...  ...  ...  ... 4.3
  1830. IDIC   ...  ...  ...  ... 7.1       sojourn time ..  ...  ... 5.1
  1831. identity of an entity ... 4.1       stochastic process .  ... 3.1
  1832. independence ..  ...  ... 8.5       stream ...  ...  ...  ... 8.7
  1833. INIQUE ...  ...  ...  2.9,5.1       SUMRY  ...  ...  ...  ... 2.9
  1834. initialization   ...  ... 2.9       T ...  ...  ...  ...  ... 3.1
  1835. INISTA ...  ...  ...  2.9,3.1       TALLY  ...  ...  ...  ... 2.9
  1836. interarrival time ..  ... 2.1       TIC .  ...  ...  ...  ... 6.4
  1837. masseges .  ...  ...  ... 5.6       time persistent statistic 3.1
  1838. matching .  ...  ...  ... 7.2       time unit   ...  ...  ... 2.1
  1839. NC ..  ...  ...  ...  ... 6.4       TR ..  ...  ...  ...  ... 2.6
  1840. NCEN   ...  ...  ...  ... 7.2       transient period ...  ... 8.4
  1841. NEIC   ...  ...  ...  ... 6.4       work station ..  ...  ... 5.6
  1842. NEXTEV ...  ...  ...  ... 4.3
  1843.